package com.hspedu.codeblock;

public class CodeBlock01 {
    public static void main(String[] args) {
        new Movie("你好，李焕英");
        new Movie("唐探3", 100, "老陈");
    }
}


class Movie{
    private String name;
    private double price;
    private String director;

    //若是三个构造器中都有下面的三行代码，就可以将其提取到一个代码块中，
    //这样不管调用哪个构造器都能执行这三行代码
    //代码块调用的顺序优先于构造器
    {
        System.out.println("电影屏幕打开");
        System.out.println("广告开始");
        System.out.println("电影正式开始");
    }

    //三个构造器重载
    public Movie(String name) {
        this.name = name;
        System.out.println(name);
    }

    public Movie(String name, double price) {
        this.name = name;
        this.price = price;
    }

    public Movie(String name, double price, String director) {
        this.name = name;
        this.price = price;
        this.director = director;
    }
}